<template>
    <div>
        <el-divider content-position="left">个人中心</el-divider>

        <div class="mysales">
            <el-input
                v-model="input.username"
                placeholder="请输入内容"
            ></el-input>
            <el-input
                placeholder="请输入密码"
                v-model="input.password"
                show-password
            ></el-input>
            <el-button type="primary" class="but" @click="upDataOne">确定修改</el-button>
        </div>
    </div>
</template>

<script>
import { createNamespacedHelpers } from "vuex";
const { mapState, mapActions } = createNamespacedHelpers("customers");
export default {
    async created() {
        const { data } = await this.getSales(localStorage.getItem("_id"));
        this.input.username = data[0].username;
        this.input.password = data[0].password;
        console.log(data, 1111111111);
        // this.input.username = this.SaleOnes[0].username
    },
    data() {
        return {
            input: {
                _id:localStorage.getItem('_id'),
                username: "",
                password: "",
            },
        };
    },
    methods: {
        ...mapActions(["getSales",'upDataOnes']),
        //确定修改
        upDataOne(){
          this.upDataOnes(this.input)
          localStorage.removeItem('token');
          localStorage.removeItem('code');
         
            this.$message({
          showClose: true,
          message: '账号密码已修改，请重新登录',
          type: 'warning'
        });
         this.$router.push('/');
        }
    },
    computed: {
        ...mapState(["SaleOnes"]),
    },
};
</script>

<style>
.mysales {
    width: 300px;
    margin: 0px auto;
}
.butt {
    margin-top: 20px;
}
</style>